package com.igoal.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.apache.commons.lang.NotImplementedException;
import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;
import org.hibernate.annotations.Type;

@Entity
@Table(name = "info_queue")
@Searchable
public class InfoQueueEntry extends BaseObject implements Audit{
	private static final long serialVersionUID = -1836588245348938103L;
	
	private Long id;
	private String email;
	private String callName;
	private boolean registered;
	private boolean reminded;
	private boolean ready;
	private Date remindedDate;
	private Date invitedDate;
	private Date createDate;
	private Date updateDate;
	
	private User invite;
	
	public InfoQueueEntry(){}
	
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @SearchableId
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	@Column(nullable = false, length = 255, unique = true)
    @SearchableProperty
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Column(nullable = true, length = 255, name="call_name")
	@SearchableProperty
	public String getCallName() {
		return callName;
	}
	public void setCallName(String callName) {
		this.callName = callName;
	}
	@Column(name = "registered", nullable = false)
    @Type(type="yes_no")
	public boolean isRegistered() {
		return registered;
	}
	public void setRegistered(Boolean registered) {
		this.registered = registered;
	}
	@Column(name = "reminded", nullable = false)
    @Type(type="yes_no")
	public boolean isReminded() {
		return reminded;
	}
	public void setReminded(Boolean reminded) {
		this.reminded = reminded;
	}
	@Column(name = "ready", nullable = false)
    @Type(type="yes_no")
	public boolean isReady() {
		return ready;
	}
	public void setReady(Boolean ready) {
		this.ready = ready;
	}
	@Column(nullable = true, name="reminded_date")
	public Date getRemindedDate() {
		return remindedDate;
	}
	public void setRemindedDate(Date remindedDate) {
		this.remindedDate = remindedDate;
	}
	@Column(nullable = true, name="invited_date")
	public Date getInvitedDate() {
		return invitedDate;
	}
	public void setInvitedDate(Date invitedDate) {
		this.invitedDate = invitedDate;
	}
	@Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false, name = "cdate")
    public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false, name= "mdate")
	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	@Override
	public boolean equals(Object o) {
		if(o != null && o instanceof InfoQueueEntry){
			InfoQueueEntry entry = (InfoQueueEntry) o;
			return entry.getEmail().equals(this.email);
		}
		return false;
	}
	@Override
	public int hashCode() {
		return email.hashCode();
	}
	@Override
	public String toString() {
		return this.email;
	}
	@Transient
	public DataStatus getStatus() {
		throw new NotImplementedException();
	}

	public void setStatus(DataStatus dataStatus) {
		throw new NotImplementedException();
	}

	@ManyToOne
	@JoinColumn(name="from_id")
	public User getInvite() {
		return invite;
	}

	public void setInvite(User invite) {
		this.invite = invite;
	}
	
}
